/*  
 * Actipro Software's WPF Docking & MDI / Prism Integration Add-on
 * http://actipro.codeplex.com/
 * 
 * Copyright (c) 2009-2015 Actipro Software LLC. 
 *  
 * This source code is subject to the terms of the Microsoft Public License (Ms-PL). 
 *  
 * Redistribution and use in source and binary forms, with or without modification, 
 * is permitted provided that redistributions of the source code retain the above 
 * copyright notices and this file header. 
 *  
 * Additional copyright notices should be appended to the list above. 
 * 
 * For details, see <http://www.opensource.org/licenses/ms-pl.html>. 
 *  
 * All other rights reserved. 
 *
 */  

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using ActiproSoftware.Windows.Controls.Docking;

namespace ActiproSoftware.Windows.Prism.Regions {

	/// <summary>
	/// Represents a base class implementation of <see cref="IDockingWindowItemTypeProvider"/>.
	/// </summary>
	public class DockingWindowItemTypeProvider : Freezable, IDockingWindowItemTypeProvider {

		#region Dependency Properties

		/// <summary>
		/// Identifies the <c>ItemType</c> dependency property.  This field is read-only.
		/// </summary>
		/// <value>The identifier for the <c>ItemType</c> dependency property.</value>
		public static readonly DependencyProperty ItemTypeProperty = DependencyProperty.RegisterAttached("ItemType",
			typeof(DockingWindowItemType), typeof(DockingWindowItemTypeProvider), new FrameworkPropertyMetadata(null));

		/// <summary>
		/// Identifies the <c>Provider</c> dependency property.  This field is read-only.
		/// </summary>
		/// <value>The identifier for the <c>Provider</c> dependency property.</value>
		public static readonly DependencyProperty ProviderProperty = DependencyProperty.RegisterAttached("Provider",
			typeof(IDockingWindowItemTypeProvider), typeof(DockingWindowItemTypeProvider), new FrameworkPropertyMetadata(null));

		#endregion // Dependency Properties

		/////////////////////////////////////////////////////////////////////////////////////////////////////
		#region INTERFACE IMPLEMENTATION
		/////////////////////////////////////////////////////////////////////////////////////////////////////

		#region IDockingWindowItemTypeProvider Members

		/// <summary>
		/// Gets the docking window item type of the specified item.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <returns>
		/// A <see cref="DockingWindowItemType"/> value.
		/// </returns>
		DockingWindowItemType IDockingWindowItemTypeProvider.GetDockingWindowItemType(object item) {
			return this.ItemType;
		}

		#endregion // IDockingWindowItemTypeProvider Members

		#endregion // INTERFACE IMPLEMENTATION

		/////////////////////////////////////////////////////////////////////////////////////////////////////
		#region PUBLIC PROCEDURES
		/////////////////////////////////////////////////////////////////////////////////////////////////////

		/// <summary>
		/// Creates a new instance of the <see cref="DockingWindowItemTypeProvider"/> class.
		/// </summary>
		/// <returns>The new instance.</returns>
		protected override Freezable CreateInstanceCore() {
			return new DockingWindowItemTypeProvider();
		}

		/// <summary>
		/// Gets or sets the item type associated with this provider.
		/// This is a dependency property.
		/// </summary>
		/// <value>
		/// The item type associated with this provider.
		/// The default value is <c>DockingWindowItemType.Document</c>.
		/// </value>
		public DockingWindowItemType ItemType {
			get { return (DockingWindowItemType)this.GetValue(ItemTypeProperty); }
			set { this.SetValue(ItemTypeProperty, value); }
		}
		/// <summary>
		/// Gets the value of the <c>ItemType</c> attached property for the specified object.
		/// </summary>
		/// <param name="obj">The object from which the property value is read.</param>
		/// <returns>The object's value.</returns>
		public static DockingWindowItemType GetItemType(DependencyObject obj) {
			if (obj == null)
				throw new ArgumentNullException("obj");
			return (DockingWindowItemType)obj.GetValue(ItemTypeProperty);
		}
		/// <summary>
		/// Sets the value of the <c>ItemType</c> attached property to the specified object. 
		/// </summary>
		/// <param name="obj">The object to which the attached property is written.</param>
		/// <param name="value">The value to set.</param>
		public static void SetItemType(DependencyObject obj, DockingWindowItemType value) {
			if (obj == null)
				throw new ArgumentNullException("obj");
			obj.SetValue(ItemTypeProperty, value);
		}

		/// <summary>
		/// Gets the value of the <c>Provider</c> attached property for the specified object.
		/// </summary>
		/// <param name="obj">The object from which the property value is read.</param>
		/// <returns>The object's value.</returns>
		public static IDockingWindowItemTypeProvider GetProvider(DependencyObject obj) {
			if (obj == null)
				throw new ArgumentNullException("obj");
			return (IDockingWindowItemTypeProvider)obj.GetValue(ProviderProperty);
		}
		/// <summary>
		/// Sets the value of the <c>Provider</c> attached property to the specified object. 
		/// </summary>
		/// <param name="obj">The object to which the attached property is written.</param>
		/// <param name="value">The value to set.</param>
		public static void SetProvider(DependencyObject obj, IDockingWindowItemTypeProvider value) {
			if (obj == null)
				throw new ArgumentNullException("obj");
			obj.SetValue(ProviderProperty, value);
		}

		#endregion // PUBLIC PROCEDURES
	}
}